<?php

namespace common\models;

use Yii;
use yii\behaviors\TimestampBehavior;

/**
 * This is the model class for table "{{%article}}".
 *
 * @property integer $id
 * @property string $article_id
 * @property string $article_name
 * @property string $content
 * @property integer $cate1
 * @property integer $cate2
 * @property integer $cate3
 * @property integer $cate4
 * @property integer $cate5
 * @property integer $weight
 * @property integer $status
 * @property string $created_at
 * @property string $updated_at
 * @property string $res1
 * @property string $res2
 * @property string $res3
 */
class Article extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return '{{%article}}';
    }

    public function behaviors()
    {
        return [
            TimestampBehavior::className(),
        ];
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['article_id', 'article_name', 'content'], 'required'],
            [['content'], 'string'],
            [[ 'weight', 'status'], 'integer'],
            [['article_id'], 'string', 'max' => 40],
            [['article_name', 'res1', 'res2', 'res3'], 'string', 'max' => 80],
            [['cate1', 'cate2', 'cate3', 'cate4', 'cate5'], 'safe'],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'article_id' => 'Article ID',
            'article_name' => '文章题目',
            'content' => '文章内容',
            'cate1' => '一级分类',
            'cate2' => '二级分类',
            'cate3' => '三级分类',
            'cate4' => '四级分类',
            'cate5' => '五级分类',
            'weight' => 'Weight',
            'status' => 'Status',
            'created_at' => 'Created At',
            'updated_at' => 'Updated At',
            'res1' => 'Res1',
            'res2' => 'Res2',
            'res3' => 'Res3',
        ];
    }
    public function getCate()
    {
        return $this->hasOne(ArticleCate::className(), ['id' => 'cate2']);
    }

}
